<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>parabola-Animation</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .wrap {
            height: 1000px;
            width: 100%;
        }

        .add {
            display: block;
            list-style: none;
            border: 1px solid #000;
            position: relative;
            height: 50px;
            width: 100%;
        }

        .add span {
            position: absolute;
            top: 0;
            right: 0;
            width: 50px;
            height: 50px;
            text-align: center;
            font-weight: 900;
            font-size: 40px;
            line-height: 50px;
        }

        footer {
            width: 100%;
            height: 50px;
            box-sizing: border-box;
            padding-right: 100px;
            background-color: #efefef;
            position: fixed;
            left: 0;
            bottom: 0;
            line-height: 50px;
            text-align: center;
        }

        .shop-car {
            width: 100px;
            height: 100%;
            position: absolute;
            top: 0;
            right: 0;
            background-color: #ccc;
        }
    </style>
</head>
<body>
<div class="wrap">
    <ul>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
        <li class="add"><span class="f-add">＋</span></li>
    </ul>
</div>
<footer id="foot">
    败家娘们
    <div class="shop-car">购物车</div>
</footer>
</body>
<script src="./parabola.js"></script>
<script>
    var doms = document.getElementsByClassName('f-add'),
        len = doms.length,
        endX = (document.body.offsetWidth - 100) / 2,
        endY = window.innerHeight - document.getElementById('foot').offsetHeight / 2,
        i;
    for (i = 0; i < len; i++) {
        doms[i].index = i;
        doms[i].addEventListener('click', function () {
            var startX = this.offsetLeft,
                startY = parseInt(this.offsetHeight * (this.index + 0.5) - window.scrollY);

            new fly({
                start: {
                    x: startX,
                    y: startY
                },
                end: {
                    x: endX,
                    y: endY
                }
            }, function () {
                console.log('动画执行完毕')
            })
        })
    }
</script>
</html>